
<%- include indexHeader %>


<%-body %>

<!-- BEGIN FOOTER -->
<%- include footer %>
<!-- END FOOTER -->
<!--时间格式化工具-->
<script src="<%=staticFilePath%>/javascripts/moment-with-locales.min.js"></script>
<script type="text/javascript">
    doraApp.controller("pagination",function($scope,$http) {

        $scope.currentPage = Number('<%=pageInfo.currentPage%>');

        $scope.totalItems = Number('<%=pageInfo.totalItems%>');

        $scope.limit = Number('<%=pageInfo.limit%>');

        $scope.startNum = Number('<%=pageInfo.startNum%>');

        $scope.totalPage = Math.ceil($scope.totalItems / $scope.limit);

        $scope.pages = [];

        $scope.sort = '<%=pageInfo.sort%>';

        $scope.time = '<%=pageInfo.time%>';

        $scope.searchKey = '<%=pageInfo.searchKey%>';


        var localUrl =  "/page";

        var sortParam = '?sort='+$scope.sort+'&time='+$scope.time+'&search='+$scope.searchKey;

        initPagination($scope,$http,localUrl,sortParam);


        var navObj = $('.soitemcontent > ul > li');

        for(var i=0;i<navObj.length;i++){
            var liObj = $(navObj[i]);
            var navId = liObj.find('a').eq(0).attr('data-value');

//                针对筛选的高亮
            if(navId == $scope.sort || navId == $scope.time){
                liObj.closest('.soitemcontent').find('a').removeClass('active');

                liObj.find('a').addClass('active');

                liObj.closest('.soitem').find('.soitemlabeltxt').eq(0).text(liObj.find('a').eq(0).text());
            }
        }


        $scope.sort = function(key){

            initPageInfo();

            $scope.sort = key;

            window.location.href = localUrl + '—'+$scope.currentPage+'.html?sort='+$scope.sort+'&time='+$scope.time+'&search='+$scope.searchKey;
        };

        $scope.time = function(key){

            initPageInfo();

            $scope.time = key;

            window.location.href = localUrl + '—'+$scope.currentPage+'.html?sort='+$scope.sort+'&time='+$scope.time+'&search='+$scope.searchKey;
        };


        $scope.processSearchForm = function(){

            initPageInfo();

            $scope.searchKey  = $('#searchByKey').val();
            $scope.currentPage = 1;
            window.location.href = localUrl + '—'+$scope.currentPage+'.html?sort='+$scope.sort+'&time='+$scope.time+'&search='+$scope.searchKey;
        };


        function initPageInfo(){

            $scope.sort = '<%=pageInfo.sort%>';

            $scope.time = '<%=pageInfo.time%>';

            $scope.searchKey = '<%=pageInfo.searchKey%>';

        }

    })
</script>
<!-- END PAGE LEVEL JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>